//----------------------------------*-C++-*----------------------------------//
/*!
 * \file   testConnect2dCart.cc
 * \author Jeremy Roberts
 * \date   11/05/2010
 * \brief  test of Connect2dCart
 * \note   Copyright (C) 2010 Jeremy Roberts
 */
//---------------------------------------------------------------------------//
// $Rev::                                               $:Rev of last commit
// $Author::                                            $:Author of last commit
// $Date:: 2010-11-27 17:06:19 -0500 (Sat, 27 Nov 2010) $:Date of last commit
//---------------------------------------------------------------------------//

#include <iostream>
#include "petscvec.h"
#include "petscsys.h"
#include "petscksp.h"
#include "../Connect2dCart.hh"
#include "../linalg/SermentVector.hh"
#include "../linalg/typedefs.hh"
using namespace std;
//---------------------------------------------------------------------------//

int main(int argc, char *args[])
{
    // initialize petsc
    PetscInitialize(&argc,&args,PETSC_NULL,PETSC_NULL);
    cout << " ________________________ " << endl;
	// "test case"
    // -- two groups
    // -- second order (i.e. 2+1 dimensions)
    // -- 2 * 2 grid = 4 elements
    // -- reflect on left and bottom
	integer g, o, e;//, bc[4];
    g  = 2;
    o  = 2;
    e  = 4;
    integer bc[4] = {1,1,1,1}; // may not work

    // create an instance of SermentMatrixCSR
    Connect2dCart C( g, o, e, bc ); 

    // verify
    cout << " C.m/n = " << C.m << " " << C.n << endl; 
    cout << " bc's are L=" << C.boundCond[0] << " R=" << C.boundCond[1] <<
                     " B=" << C.boundCond[2] << " T=" << C.boundCond[3] << endl;

    // now build the element
    //    1 1
    //    1 1
    integer rows, cols;
    rows = 2;
    cols = 2;

    vector<vector<integer> > el;
    el.resize(rows);
    for(integer i = 0; i < rows; ++i)
    {
        el[i].resize(cols);
    }
    el[0][0] = 1; el[0][1] = 2;
    el[1][0] = 3; el[1][1] = 4;
    C.buildMe( el );
    cout << C.elements[0][0] << C.elements[0][1] << C.elements[1][0] <<
            C.elements[1][1] << endl;

    C.viewMe();

    for(integer i = 0; i < C.littleMsize; i++)
        cout << " i=" << C.littleMidxx[i] << " j=" << C.littleMidxy[i] << " val=" << C.littleM[i] << endl;


	PetscFinalize();

	cout << "  ... all finished. now check for errors! " << endl;

    return 0;
}

//---------------------------------------------------------------------------//
//                 end of testConnect2dCart.cc
//---------------------------------------------------------------------------//

